package listdemo;

import java.util.*;

/**
 * @Author 12629
 * @Description：
 */
public class Test {

    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("JavaSE");
        list.add("JavaWeb");
        list.add("JavaEE");
        list.add("JVM");
        list.add("测试课程");
        System.out.println(list);
        System.out.println("========for=======");

        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));
        }
        System.out.println("======foreach=========");

        for (String x : list) {
            System.out.println(x);
        }
        System.out.println("======迭代器1=========");

        Iterator<String> it =  list.iterator();
        while (it.hasNext()) {
            System.out.println(it.next());
        }
        System.out.println("======迭代器2=========");
        ListIterator<String> it2 =  list.listIterator();
        while (it2.hasNext()) {
            System.out.println(it2.next());
        }

       /* List<String> ret = list.subList(1,3);
        System.out.println(ret);

        System.out.println("=======更新=======");
        ret.set(0,"gaobo");
        System.out.println(list);
        System.out.println(ret);*/
    }


    public static void main3(String[] args) {

        ArrayList<Integer> arrayList1 = new ArrayList<>();//顺序表大小是0

        arrayList1.add(1);// 大小变为了10

        arrayList1.add(2);

        arrayList1.add(3);
        //........ 当这10个放满了之后，需要扩容，扩容才去的是1.5倍的扩容方式

        System.out.println(arrayList1);
        ArrayList<Integer> arrayList2 = new ArrayList<>(15);
        ArrayList<Integer> arrayList3 = new ArrayList<>(arrayList1);
        LinkedList<Integer> list = new LinkedList<>();
        ArrayList<Integer> arrayList4 = new ArrayList<>(list);
    }

    public static void main2(String[] args) {
        MyArrayList myArrayList = new MyArrayList();
        myArrayList.add(0,1);
        myArrayList.add(1,2);
        myArrayList.add(2,3);
        myArrayList.add(31);
        myArrayList.display();
        System.out.println(myArrayList.contains(1));
        System.out.println(myArrayList.indexOf(1));
        System.out.println(myArrayList.get(1));
        myArrayList.set(0,99);
        myArrayList.display();
    }

    public static int max(int a,int b) {
        return Math.max(a,b);
    }

    public static double max(double a,double b,double c) {
        double m = Math.max(a,b);
        return Math.max(m,c);
    }


    public static void main1(String[] args) {
        List<Integer> list = new ArrayList<>();

        List<Integer> list2 = new LinkedList<>();

        List<Integer> list3 = new Stack<>();

        System.out.println("=====================");

        ArrayList<Integer> list11 = new ArrayList<>();

        LinkedList<Integer> list22 = new LinkedList<>();

        Stack<Integer> list33 = new Stack<>();

    }
}
